package com.only4play.productcenter.domain.product;

import com.only4play.common.constants.BaseEnum;

import java.util.Optional;

public enum ProductType implements BaseEnum<ProductType> {

  SINGLE(1, "单品"),
  PACKAGE(2, "套餐"),
  ;

  ProductType(Integer code, String name) {
    this.code = code;
    this.name = name;
  }

  private Integer code;
  private String name;

  @Override
  public Integer getCode() {
    return this.code;
  }

  @Override
  public String getName() {
    return this.name;
  }

  public static Optional<ProductType> of(Integer code) {
    return Optional.ofNullable(BaseEnum.parseByCode(ProductType.class, code));
  }

}
